package com.hzya.frame.web.listener;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.Map;

/**
 *
 * @author 郭军辉
 *
 * 2018/5/13 下午2:54:55
 *
 */
public class ServletContextListenerImpl implements ServletContextListener {

    protected Logger logger = LogManager.getLogger(getClass());
    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        logger.info("======================== 应用程序关闭成功 ================================");
        ServletContext application = sce.getServletContext();

        Map userSessionMap = (Map) application.getAttribute("usersessionmap");

//        String thisUserCode = null;
//        WebApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(application);
    }

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        logger.info("======================== 应用程序启动成功 ========================");
        ServletContext application = sce.getServletContext();
        String basePath=application.getContextPath();
        application.setAttribute("base",basePath);

    }

}
